from flask import Flask, request, jsonify
from flask_cors import CORS
# from main import download_and_save_image
from main import downloadImage
app = Flask(__name__)

CORS(app, origins=["*"])
@app.route('/', methods=['POST'])
def process():
    # print(request.args.get('urls'))
    # url = request.args.get('urls')
    url = request.json.get('urls')
    name = request.json.get('name')

    result = downloadImage(url,name,request.headers)
    # data = request.get_json()
    # 这里可以进行 Python 处理逻辑     https://94.140.0.4/tupian/forum/202412/17/144933w0jhesihaa3alchc.jpeg
    # result = download_and_save_image(url)
    # result = {'message': f'接收到的数据是:{url}'}
    return result

if __name__ == '__main__':
    app.run(debug=True)